package com.aysf.drafter;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;

import java.nio.file.Paths;

/**
 * author: MaoZz
 * datetime:2024/10/16 15:31
 */
public class Gen {


    public static void main(String[] args) {

        FastAutoGenerator.create("jdbc:mysql:///dr?serverTimezone=UTC", "root", "123456")
                .globalConfig(builder -> builder
                        .author("MaoZz")
                        .outputDir(Paths.get(System.getProperty("user.dir")) + "/src/main/java")
                        .commentDate("yyyy-MM-dd HH:mm:ss")
                )
                .packageConfig(builder -> builder
                        .parent("com.aysf.drafter")
                        .entity("entity")
                        .mapper("mapper")
                        .service("service")
                        .serviceImpl("service.impl")
                        .xml("mapper")
                )
                .strategyConfig(builder -> {
                    builder.addInclude("admin") // 设置需要生成的表名
                            .entityBuilder()
                            .enableLombok() // 启用 Lombok
                            .enableTableFieldAnnotation() // 启用字段注解
                            .controllerBuilder()
                            .enableRestStyle(); // 启用 REST 风格
                })
                .execute();
    }
}
